<%--
  Created by IntelliJ IDEA.
  User: wuxin
  Date: 2024/7/13
  Time: 14:14
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>二级联动</title>

    　<script src="http://libs.baidu.com/jquery/2.1.4/jquery.min.js"></script>

    <script type="text/javascript">
        $(document).ready(function (){
                $("#college").change(function (){

                    var teacherSel=$("#teacher");
                    teacherSel.find("option:not(first)").remove();
                    var collegeId= this.value;
                    if(collegeId){
                        $.ajax({
                            url:"${pageContext.request.contextPath}/ajaxTeacherList.action",
                            data:{"collegeId":collegeId},
                            dataType:"json",
                            success:function(data){
                                $(data).each(function (){
                                    teacherSel.append(new Option(this.tname,this.tid));
                                });
                            }
                        });
                    }


                });
        }


        );

    </script>



</head>
<body>

<select id="college">
    <option>请选择</option>
    <c:forEach items="${collegeList}" var="cl">
        <option value="${cl.cid}">${cl.cname}</option>
    </c:forEach>
</select>




<select id="teacher">
    <option>请选择</option>

</select>

</body>
</html>
